<!-- stories/templates/stories/base.html -->
{% load static %}
{% load story_extras %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}AI故事生成网站{% endblock %}</title>
    <link rel="stylesheet" href="{% static 'css/style.css' %}">
    <link rel="stylesheet" href="{% static 'css/navbar.css' %}">
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar">
        <div class="container">
            <!-- Logo 居左 -->
            <div class="nav-logo">
                <a href="{% url 'stories:home' %}"><img src="{% static 'images/web_site_logo.png' %}" alt="AI故事生成网站"></a>
            </div>
            
            <!-- 导航菜单 居中 -->
            <ul class="nav-menu">
                <li><a href="{% url 'stories:home' %}" {% if request.resolver_match.url_name == 'home' %}class="active"{% endif %}>首页</a></li>
                <li><a href="{% url 'stories:ai_story_generator' %}" {% if request.resolver_match.url_name == 'ai_story_generator' %}class="active"{% endif %}>AI故事生成</a></li>
                <li><a href="{% url 'stories:story_library' %}" {% if request.resolver_match.url_name == 'story_library' %}class="active"{% endif %}>故事库</a></li>
                <li><a href="{% url 'stories:leaderboard' %}" {% if request.resolver_match.url_name == 'leaderboard' %}class="active"{% endif %}>排行榜</a></li>
                <li><a href="{% url 'stories:my_stories' %}" {% if request.resolver_match.url_name == 'my_stories' %}class="active"{% endif %}>我的创作</a></li>
            </ul>
            
            <!-- 用户区域 居右 -->
            <ul class="nav-user">
                {% if user.is_authenticated %}
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle">个人中心 ▼</a>
                        <ul class="dropdown-menu">
                            <li><a href="{% url 'stories:profile' %}">个人资料</a></li>
                            <li><a href="{% url 'stories:change_password' %}">修改密码</a></li>
                            {% if user.is_admin %}
                                <li><a href="{% url 'stories:admin_review' %}">审核中心</a></li>
                                <li><a href="{% url 'stories:admin_dashboard' %}">数据统计</a></li>
                            {% endif %}
                            <li><a href="{% url 'stories:logout' %}">退出登录</a></li>
                        </ul>
                    </li>
                    <li class="user-info">
                        <span>欢迎，{{ user.username }}{% if user.is_admin %} (管理员){% endif %}</span>
                    </li>
                {% else %}
                    <li><a href="{% url 'stories:login' %}">登录</a></li>
                    <li><a href="{% url 'stories:register' %}">注册</a></li>
                {% endif %}
            </ul>
            
            <div class="nav-toggle">
                <span></span>
                <span></span>
                <span></span>
            </div>
        </div>
    </nav>

    <!-- 主要内容 -->
    <main class="main-content">
        {% if messages %}
            <div class="messages">
                {% for message in messages %}
                    <div class="alert alert-{{ message.tags }}">{{ message }}</div>
                {% endfor %}
            </div>
        {% endif %}

        {% block content %}
        {% endblock %}
    </main>

    <!-- 页脚 -->
    <footer class="footer">
        <div class="container">
            <p>&copy; 2025 梦笔生花-AI故事生成网站 保留所有权利.</p>
        </div>
    </footer>

    <script src="{% static 'js/main.js' %}"></script>
    <script src="{% static 'js/navbar.js' %}"></script>
    {% block extra_js %}
    {% endblock %}
</body>
</html>